package com.xcc.goods.controller;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xcc.common.domain.entry.Goods;
import com.xcc.common.domain.service.GoodsService;
import com.xcc.common.result.ResultBody;
import com.xcc.error.UserErrorService;
import com.xcc.feign.UserFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author frosty
 * @description
 * @date 2019-11-20 20:11:29
 */

@RestController
public class GoodsController {

   @Resource
   private UserFeignService userFeignService;

    @Autowired
    private GoodsService goodsService;

  /* @GetMapping("/list")
    public  ResultBody list( @RequestParam(required = false) Map<String,Object> map){
        return  userFeignService.list(map);

    }*/

    @GetMapping("/getU")
    public  ResultBody getU(String  token){
        System.out.println(token);
        return  /*userFeignService.getU();*/ null;

    }

    @GetMapping("/add")
    public  ResultBody add(Goods goods){

     /*商品状态  -1未上架  1 正常*/
        goods.setState(0);
        goods.setId(IdWorker.getIdStr());
         boolean save = goodsService.save(goods);
         if(save){
             return  ResultBody.success("save is success");
         }

        return  ResultBody.success("save is fail");
    }

    @PostMapping("/list")
    public  ResultBody list(@RequestBody(required = false) Map<String,Object> map){
        System.out.println(map);
              return userFeignService.list(map);
    }





}
